package com.cqq.auth.service;

import java.util.List;
import java.util.Map;

import com.cqq.auth.service.bean.OrganizationBean;
import com.cqq.auth.service.bean.OrganizationQueryBean;
import com.cqq.auth.service.exception.OrganizationServiceException;

/**
 * <h3>组织服务接口</h3>
 * 
 * @author xijq
 * @version 1.0.0
 * 
 */
public interface OrganizationService {

	/**
	 * <h3>添加组织</h3>
	 * 
	 * @param org OrganizationBean
	 * 
	 * @throws OrganizationServiceException
	 */
	public OrganizationBean addOrganization(OrganizationBean org) throws OrganizationServiceException;

	/**
	 * <h3>更新组织</h3>
	 * 
	 * @param org OrganizationBean
	 * 
	 * @throws OrganizationServiceException
	 */
	public void updateOrganization(OrganizationBean org) throws OrganizationServiceException;

	/**
	 * <h3>删除组织</h3>
	 * 
	 * @param id 组织ID
	 * 
	 */
	public void deleteOrganization(Integer id) throws OrganizationServiceException;
	
	/**
	 * <h3>查询组织信息</h3>
	 * 
	 * @param id 组织ID
	 * 
	 * @return OrganizationBean
	 * 
	 */
	public OrganizationBean findOrganization(Integer id);
	
	/**
	 * <h3>查询组织列表</h3>
	 * 
	 * @param ids 组织ID数组
	 * 
	 * @return OrganizationBean List
	 * 
	 */
	public List<OrganizationBean> listOrganization(Integer[] ids);
	
	/**
	 * <h3>按父组织ID查询组织列表</h3>
	 * 
	 * @param parentId 父组织ID
	 * 
	 * @return OrganizationBean List
	 * 
	 */
	public List<OrganizationBean> listOrganizationByParentId(Integer parentId);
	
	/**
	 * <h3>按组织名称查询组织列表</h3>
	 * 
	 * @param name 组织名称
	 * @param parentId 父组织ID
	 * 
	 * @return OrganizationBean List
	 * 
	 */
	public List<OrganizationBean> listOrganizationByName(String name,Integer parentId);
	
	/**
	 * <h3>按用户ID查询所属组织列表</h3>
	 * 
	 * @param userId 用户ID
	 * 
	 * @return OrganizationBean List
	 * 
	 */
	public List<OrganizationBean> listOrganizationByUser(Integer userId);
	
	
	/**
	 * <h3>统计各组织层级下的用户数量</h3>
	 * 
	 * @param parentId 父组织ID
	 * 
	 * @return OrganizationBean List
	 * 
	 */
	public Map<Integer,Integer> countUserByParentId(Integer parentId);
	
	
	/**
	 * <h3>按组织名称查询下级组织列表</h3>
	 * 
	 * @param name 组织名称
	 * @param parentId 父组织ID
	 * 
	 * @return OrganizationBean List
	 * 
	 */
	public List<OrganizationBean> listChildrenOrgByName(String name,Integer parentId);
	
	
	public List<OrganizationBean> queryOrgByParentId(OrganizationQueryBean queryBean);
	
	/**
	 * 根据用户ID 和顶级组织  查询用户所属组织在顶级组织下的组织
	 * @param userId
	 * @param parentId
	 * @return
	 */
	public List<OrganizationBean> listOrganizationByUser(Integer userId,Integer parentId);
	
}
